from socket import *
#tcp客户端开发
tcp_socket = socket(AF_INET,SOCK_STREAM)
#注意和udp通信时区别,显示绑定端口,tcp通信时四次挥手时的状态变化
#tcp_socket.bind(('', 9999))
tcp_addr_port = ('192.168.56.1',8080)
tcp_client_socket = tcp_socket.connect(tcp_addr_port)
for i in range(4):
    data = '我喜欢你! '
    data_bytes = data.encode('utf-8')
    tcp_socket.send(data_bytes)
recv_data = tcp_socket.recv(1024)
print(f"接收到服务器发送过来的数据: {recv_data.decode('utf-8')}")
tcp_socket.close()